﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using L = Science.Mathematics.LinearAlgebra;

namespace Strang3Ed.Chapter03.Section4
{
    public class ExampleC
    {
        public ExampleC()
        {
        }
        private string result;
        public string Result
        {
            get { return result; }
        }
        public void Compute()
        {
            double[,] x = { { 1.0, 2.0, 1.0, 0.0}, 
                            { 2.0, 4.0, 4.0, 8.0},
                            { 4.0, 8.0, 6.0, 8.0} };

            L.Matrix A = new L.Matrix(x);

            double[] y = { 4.0, 2.0, 10.0 };

            L.Vector b = new L.Vector(y);

            L.LinearEquationGeneral eq = new L.LinearEquationGeneral(A, b);
            eq.Solve();

            result += eq.ParticularSolution.ToString() + "\r\n";
            result += eq.SpecialSolution.ToString();
            foreach (int k in eq.FreeVariable) result += k.ToString() + "   ";
        }
    }
}
/*
7
0
-3
0

-2     4     
1     0     
0     -4     
0     1     

1   3   // index runs from 0 to 3 so x_2 and x_4 are free variables. 
*/

